load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//bzl:cpp_unittest.bzl", "cpp_unittest")

# TODO(kgk): Fix test.
# cc_binary(
#     name = "cache_locality_benchmark",
#     srcs = ["CacheLocalityBenchmark.cpp"],
#     deps = [
#         "//folly:benchmark",
#         "//folly/concurrency:cache_locality",
#         "//folly/lang:keep",
#         "@glog",
#     ],
# )

cpp_unittest(
    name = "cache_locality_test",
    srcs = ["CacheLocalityTest.cpp"],
    deps = [
        "//folly/concurrency:cache_locality",
        "//folly/portability:gtest",
        "//folly/portability:sys_resource",
        "//folly/portability:unistd",
        "//folly/test:test_utils",
        "@fmt",
        "@glog",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "atomic_shared_ptr_test",
#     srcs = [
#         "AtomicSharedPtrCounted.h",
#         "AtomicSharedPtrTest.cpp",
#     ],
#     deps = [
#         "//folly:portability",
#         "//folly/concurrency:atomic_shared_ptr",
#         "//folly/portability:config",
#         "//folly/portability:gflags",
#         "//folly/portability:gtest",
#         "//folly/test:deterministic_schedule",
#         "@glog",
#     ],
# )

cc_binary(
    name = "atomic_shared_ptr_performance",
    srcs = ["AtomicSharedPtrPerformance.cpp"],
    deps = [
        "//folly/concurrency:atomic_shared_ptr",
        "//folly/portability:config",
    ],
)

cpp_unittest(
    name = "core_cached_shared_ptr_test",
    srcs = ["CoreCachedSharedPtrTest.cpp"],
    deps = [
        "//folly:benchmark",
        "//folly:portability",
        "//folly/concurrency:atomic_shared_ptr",
        "//folly/concurrency:core_cached_shared_ptr",
        "//folly/concurrency:thread_cached_synchronized",
        "//folly/concurrency/memory:read_mostly_shared_ptr",
        "//folly/portability:config",
        "//folly/portability:gtest",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "concurrent_hash_map_test",
#     srcs = ["ConcurrentHashMapTest.cpp"],
#     deps = [
#         "//folly:traits",
#         "//folly/concurrency:concurrent_hash_map",
#         "//folly/container/test:tracking_types",
#         "//folly/hash",
#         "//folly/portability:gflags",
#         "//folly/portability:gtest",
#         "//folly/synchronization:latch",
#         "//folly/test:deterministic_schedule",
#     ],
# )

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "concurrent_hash_map_test_no_simd",
#     srcs = ["ConcurrentHashMapTest.cpp"],
#     local_defines = ["FOLLY_F14_FORCE_FALLBACK=1"],
#     deps = [
#         "//folly:traits",
#         "//folly/concurrency:concurrent_hash_map",
#         "//folly/container/test:tracking_types",
#         "//folly/hash",
#         "//folly/portability:gflags",
#         "//folly/portability:gtest",
#         "//folly/synchronization:latch",
#         "//folly/test:deterministic_schedule",
#     ],
# )

cpp_unittest(
    name = "dynamic_bounded_queue_test",
    srcs = ["DynamicBoundedQueueTest.cpp"],
    deps = [
        "//folly:mpmc_queue",
        "//folly:producer_consumer_queue",
        "//folly/concurrency:dynamic_bounded_queue",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
        "@glog",
    ],
)

cpp_unittest(
    name = "priority_unbounded_queue_set_test",
    srcs = ["PriorityUnboundedQueueSetTest.cpp"],
    deps = [
        "//folly/concurrency:priority_unbounded_queue_set",
        "//folly/container:enumerate",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "unbounded_queue_test",
    srcs = ["UnboundedQueueTest.cpp"],
    deps = [
        "//folly:mpmc_queue",
        "//folly:producer_consumer_queue",
        "//folly/concurrency:unbounded_queue",
        "//folly/lang:keep",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
        "@boost.thread",
        "@glog",
    ],
)

cpp_unittest(
    name = "thread_cached_synchronized_test",
    srcs = ["ThreadCachedSynchronizedTest.cpp"],
    deps = [
        "//folly/concurrency:thread_cached_synchronized",
        "//folly/lang:keep",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "process_local_unique_id_test",
    srcs = ["ProcessLocalUniqueIdTest.cpp"],
    deps = [
        "//folly:synchronized",
        "//folly/concurrency:process_local_unique_id",
        "//folly/portability:gtest",
    ],
)

cc_binary(
    name = "singleton_relaxed_counter_bench",
    srcs = [
        "SingletonRelaxedCounterBench.cpp",
    ],
    deps = [
        "//folly:benchmark",
        "//folly/concurrency:singleton_relaxed_counter",
        "//folly/init",
        "//folly/lang:keep",
        "//folly/portability:gflags",
        "@boost.thread",
    ],
)

cpp_unittest(
    name = "singleton_relaxed_counter_test",
    srcs = [
        "SingletonRelaxedCounterTest.cpp",
    ],
    deps = [
        "//folly:thread_local",
        "//folly/concurrency:singleton_relaxed_counter",
        "//folly/portability:gtest",
        "@boost.thread",
    ],
)
